import 'package:flutter_module/map/dispatcher/ni_map_layer_manager_dispacther.dart';
import 'package:flutter_module/map/dispatcher/ni_map_viewport.dispacther.dart';

import 'library_dispatcher.dart';
import 'ni_map_base_dispacther.dart';
import 'ni_map_polygon_dispacther.dart';

class NIMapDispatcherFactory {
  // 工厂模式
  factory NIMapDispatcherFactory() => _getInstance();

  static NIMapDispatcherFactory get instance => _getInstance();
  static final NIMapDispatcherFactory _instance =
      NIMapDispatcherFactory._internal();

  late NIAnimationDispatcher _animationDispatcher;
  late NIMarkerDispatcher _markerDispatcher;
  late NILocationDispatcher _locationDispatcher;
  late NILineDispatcher _lineDispatcher;
  late NIPolygonDispatcher _polygonDispatcher;
  late NIBaseDispatcher _baseDispatcher;
  late NIViewportDispatcher _viewportDispatcher;
  late NILayerManagerDispatcher _layerManagerDispatcher;

  NIMapDispatcherFactory._internal() {
    _animationDispatcher = NIAnimationDispatcher();
    _markerDispatcher = NIMarkerDispatcher();
    _locationDispatcher = NILocationDispatcher();
    _lineDispatcher = NILineDispatcher();
    _polygonDispatcher = NIPolygonDispatcher();
    _baseDispatcher = NIBaseDispatcher();
    _viewportDispatcher = NIViewportDispatcher();
    _layerManagerDispatcher = NILayerManagerDispatcher();
  }

  static NIMapDispatcherFactory _getInstance() {
    return _instance;
  }

  /// 地图基础操作控制
  NIBaseDispatcher get baseDispatcher => _baseDispatcher;

  /// 地图动画控制
  NIAnimationDispatcher get animationDispatcher => _animationDispatcher;

  /// marker 控制
  NIMarkerDispatcher get markerDispatcher => _markerDispatcher;

  /// 定位图层控制
  NILocationDispatcher get locationDispatcher => _locationDispatcher;

  /// 线控制
  NILineDispatcher get lineDispatcher => _lineDispatcher;

  /// 面控制
  NIPolygonDispatcher get polygonDispatcher => _polygonDispatcher;

  /// 视窗控制
  NIViewportDispatcher get viewportDispatcher => _viewportDispatcher;

  /// LayerManager 控制
  NILayerManagerDispatcher get layerManagerDispatcher =>
      _layerManagerDispatcher;
}
